package io.wdb.modules.generator.generator.controller.book;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;

import io.wdb.common.utils.PageUtils;
import io.wdb.common.utils.Query;
import io.wdb.common.utils.R;
import io.wdb.modules.generator.generator.entity.customer.BookInfoEntityCustomer;
import io.wdb.modules.generator.generator.service.BookBatchImportService;

@RestController
@RequestMapping("book/import")
public class BatchImportController {
	
	@Autowired
	private BookBatchImportService bookBatchImportService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	//@RequiresPermissions("accountcash:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        String paramToken = (String) params.get("currentTime");
        if(paramToken==null||paramToken.equals("")) {
        	return R.ok();
        }
        String currentTime = paramToken.split("-")[1];
        Query query = new Query(params);
        query.put("currentTime", currentTime);
        List<BookInfoEntityCustomer> bookInfoEntityCustomers = bookBatchImportService.list(query);
        PageInfo<BookInfoEntityCustomer> page = new PageInfo<BookInfoEntityCustomer>(bookInfoEntityCustomers);
		int total = (int) page.getTotal();
        PageUtils pageUtil = new PageUtils(bookInfoEntityCustomers, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
}
